Skip to content

Conversation

@quintinali
Copy link
Contributor

test case for log ingestion and preprocessing

@asfgit
Copy link

asfgit commented Nov 30, 2018

Can one of the admins verify this patch?

@quintinali
Copy link
Contributor Author

@fgreg @lewismc Could you please take a look at the code. As I mentioned in the last meeting, the EmbeddedElasticsearchServer can not work in the code and I can not fix it. Could anyone help me to figure out what the problem is? If you compile the code, please use command "mvn clean install -Dskiptests", or the unit test will fail. I run these unit test cases with eclipses and a elasticsearch engine installed on my computer.

@lewismc lewismc changed the title Sdap 161 SDAP-161 MUDROD embedded unit test Nov 30, 2018
Copy link
Member

@lewismc lewismc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quintinali please please please remember. The source code is formatted at 2 space indents not 4. Please ensure that your code is formatted to 2 space indents.
Please see my comments... there is a lot we need to improve here before we can go forward.

LOG.info("Processing logs dated {}", anInputList);

DiscoveryStepAbstract im = new ImportLogFile(this.props, this.es, this.spark);
/* DiscoveryStepAbstract im = new ImportLogFile(this.props, this.es, this.spark);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, the issue SDAP-161 is described as being MUDROD embedded unit test there should therefore be no code other than en embedded Unit test...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, if you are going to comment out code that you do not intend to use... just remove it.


DiscoveryStepAbstract hg = new HistoryGenerator(this.props, this.es, this.spark);
hg.execute();
/*DiscoveryStepAbstract hg = new HistoryGenerator(this.props, this.es, this.spark);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here...

} catch (Exception e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true);
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", options, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is buggy. We just want to throw the Exception... not continuously print the help arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quintinali please address this. It should not throw help. It should through the Exception e

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lewismc In my computer, the old code (
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true)) comes with an error “The method printHelp(String, Options) in the type HelpFormatter is not applicable for the arguments (String, boolean)”

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK what I am saying is that this code should be changed to the following

} catch (Exception e) {
  throw new RuntimeException(e)
}

...or something similar.


public class RequestUrlTest {

// @BeforeClass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never leave code commented out like this it is extremely untidy.

@Test
public void testuRLRequest() {
RequestUrl url = new RequestUrl();
String strURL = "https://podaac.jpl.nasa.gov/datasetlist?ids=Collections:Measurement:SpatialCoverage:Platform:Sensor&values=SCAT_BYU_L3_OW_SIGMA0_ENHANCED:Sea%20Ice:Bering%20Sea:ERS-2:AMI&view=list";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not a constant?

@@ -0,0 +1,18 @@
package org.apache.sdap.mudrod.weblog.structure.log;

import static org.junit.Assert.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never use wildcard imports.

Assert.assertEquals("failed in geoip function!", "22.283001,114.150002", result.latlon);
}

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot ship binary code inside of source code management... the resources below should be decompressed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is there any reason we are using logs from 2015? Why not 2018?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot understand which resource do you mean should be decompressed? There is not a specific reason for choosing logs from 2015.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/FTP.201502.w1.gz and
core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/WWW.201502.w1.gz

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have not addressed this issue. The files should not be in the compressed form... you need to decompress them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remembered that @fgreg has added a function of decompressing zip log file for MUDROD. And the test code can parse the two gz. file. If you need, I can depress them for you. Is it necessary?

1. formatter
2. remove useless import
@quintinali
Copy link
Contributor Author

@lewismc I revised the code as you required. Could you please take a look at the unit test cases and please let me know whether they are the test case your team needs?

Copy link
Member

@lewismc lewismc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quintinali thanks for making some updates. Please see the remainder of my comments.

} catch (Exception e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true);
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", options, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quintinali please address this. It should not throw help. It should through the Exception e

String viewquery = "";
try {
String infoStr = requestURL.getSearchInfo(viewnode.getRequest());
//String infoStr = requestURL.getSearchInfo(viewnode.getRequest());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to resolve this.


@AfterClass
public static void tearDown() {
// TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove TODO and method if nothing happens here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve most issued metioned above except the first one. In my computer, the old code (
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true)) comes with an error “The method printHelp(String, Options) in the type HelpFormatter is not applicable for the arguments (String, boolean)”

public void testDeleteAllByQuery() {
es.deleteAllByQuery("mudrod", "MetadataLinkage", QueryBuilders.matchAllQuery());

// String res = es.searchByQuery("mudrod", "MetadataLinkage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

/*
* @Test public void testMakeClient() {
*
* try { Client client = es.makeClient(mudrodEngine.loadConfig()); assert
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if not used. Why is it not being used?

/*
* @Test public void testSetClient() {
*
* try { Client client = es.makeClient(mudrodEngine.loadConfig());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if not being used... why is it not being used?

* tests are implemented, this is merely in place to get the JaCoCo test reporting to
* work.
* Initial test case for {@link org.apache.sdap.mudrod.main.MudrodEngine},
* currently no tests are implemented, this is merely in place to get the JaCoCo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no tests are implemented then this is a TODO and a JIRA issue should be logged such that someone knows that a test needs to be written.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I delete the test class for MudrodEngine and will add it in the future

Assert.assertEquals("failed in geoip function!", "22.283001,114.150002", result.latlon);
}

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/FTP.201502.w1.gz and
core/src/test/resources/Testing_Data_1_3dayLog+Meta+Onto/WWW.201502.w1.gz

@quintinali
Copy link
Contributor Author

@lewismc I solved most issued based on your comments. Could you please take a look at my explanation when you have time, especially for this one #35 (comment)

Besides, sorry that I missed some comments before since some conversations were displayed in a hidden mode and I didn't notice that.

Copy link
Member

@lewismc lewismc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for update @quintinali please see my new comments.

} catch (Exception e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", true);
formatter.printHelp("MudrodEngine: 'dataDir' argument is mandatory. " + "User must also provide an ingest method.", options, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK what I am saying is that this code should be changed to the following

} catch (Exception e) {
  throw new RuntimeException(e)
}

...or something similar.

}

private static String getTestDataPath() {
File resourcesDirectory = new File("src/test/resources/");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be addressed using the ClassLoader. Something like

getClass().getClassLoader().getResource... or getResourceAsStream...

You need to make this change rather than passing around File objects OK.

return node.client();
}

public void shutdown() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this method if it has no content and you are not overriding anything.

import org.junit.BeforeClass;

/**
* This is a helper class the starts an embedded elasticsearch server for each
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you have addressed the comments here fully I will test the code locally and provide input as to why it is not working.


@Test
public void testCustomAnalyzingStringString() {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace


@Test
public void testGenerateUpdateRequestStringStringStringMapOfStringObject() {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace


@Test
public void testGetDocCountStringStringArray() {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace


@Test
public void testGetDocCountStringArrayStringArray() {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace


@Test
public void testGetDocCountStringArrayStringArrayQueryBuilder() {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace

Assert.assertEquals("failed in geoip function!", "22.283001,114.150002", result.latlon);
}

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have not addressed this issue. The files should not be in the compressed form... you need to decompress them.

@quintinali
Copy link
Contributor Author

@lewismc I revised code based on your comments. Please take a look at the embedded elasticsearch engine when you have time. Thanks.

For the compressed logs, MUDROD has the capability to decompress them. Please check the attached figure.

image

quintinali and others added 6 commits January 15, 2019 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants